<?php

class omekpi_mdl_pickinger_log extends dbeav_model{
    function getPageData($where=''){
            return $this->db->select('SELECT sdb_omekpi_pickinger_log.* , sdb_omekpi_employee.* ' .
                    'FROM `sdb_omekpi_pickinger_log` INNER JOIN sdb_omekpi_employee ' .
                    'ON sdb_omekpi_pickinger_log.employee_id = sdb_omekpi_employee.employee_id and employee_type='."'".'pickinger'."' ".$where);
    }
    
    function getCount($where=''){
        $array=array();
        $count = $this->db->select('select pick_numbers,picked_numbers from sdb_omekpi_pickinger_log '.$where.' limit 1');
        if($count){ 
            foreach($count as $key=>$value){
                $array =  $value;
            }
        }
        $sum = $this->db->select( 'select sum(my_picked_numbers) as count_my_picked_numbers from sdb_omekpi_pickinger_log '.$where);
        foreach($sum as $k=>$v){
            return array_merge($array,$v);
        }
    }

    function search($where){
        return $this->db->select("SELECT * FROM sdb_omekpi_pickinger_log ".$where);
    }
    
    function getContentPickedCount(){
        $count = $this->db->select('select picked_numbers from sdb_omekpi_pickinger_log limit 1');
        foreach($count as $v){
            return $v['picked_numbers'];
        }
    }
    
    function update_mypicked($array){
        $this->db->exec("update sdb_omekpi_pickinger_log set my_picked_numbers='".$array['my_picked_numbers'].
        "' where employee_id='".$array['employee_id']."' and createdate='".$array['createdate']."'");
    }
    
    function update_packaged($allcount){
        return $this->db->exec("update sdb_omekpi_pickinger_log set picked_numbers='".$allcount."'");
    }
    
    function updateCount($count,$allcount){
        return $this->db->exec('update sdb_omekpi_pickinger_log set pick_numbers='.$count.',picked_numbers='.$allcount);
    }
}
?>
